<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
	<meta charset="UTF-8">
	<title>兑换</title>
	<meta name="description" content="">
	<meta name="keywords" content="">
	<meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
	<meta name="format-detection" content="telephone=no,email=no,adress=no" />
	<meta name="apple-mobile-web-app-capable" content="yes" />  
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<link rel="stylesheet" href="{THEME_PATH}styles/swiper.min.css">
	<link rel="stylesheet" href="{THEME_PATH}styles/reset.css">
	<link rel="stylesheet" href="{THEME_PATH}styles/common.css">
	<link rel="stylesheet" href="{THEME_PATH}styles/style.css">	
</head>
<body>
	<div class="exchange-head relative">
		<img src="{THEME_PATH}images/exchange.jpg" alt="" width="100%" class="img-responsive">
		<ul class="top">
			<li class="fl">
				<a href="/index.php?m=user&c=exchange&a=introduce">
					<i class="iconfont">&#xe6a2;</i>玩法介绍
				</a>
			</li>
			<li class="fr">
				<a href="/index.php?m=user&c=exchange&a=touzhu_records">
					<i class="iconfont">&#xe6a1;</i>投注记录
				</a>
			</li>
		</ul>
		<div class="con">
			<p>当前奖池</p>
			<h2 class="num"><?php echo round($Jackpot['value'],6); ?></h2>
			<!-- <h2 class="num"><?php echo $Jackpot['value']; ?></h2> -->
			<p>GF</p>
		</div>
	</div>
	<!-- S 公告 -->
	<div class="notice-wrap flex">
		<i class="iconfont">&#xe69c;</i>
		<div id="announcement" class="swiper-container flex-1">
			<div class="swiper-wrapper">
				<?php if($records) : ?>

					<?php foreach($records as $key => $value){
						$username = str_replace(substr($value['username'],3,4),'****',$value['username']);
						echo '<div class="swiper-slide"><a href="#">恭喜'.$username.'喜中'.$value['reward_prize'].'升值链</a></div>';
					}?>
				<!-- <div class="swiper-slide">
					<a href="#">恭喜 喜中200升值链</a>
					</div> -->
				<?php endif ?>
				
				
			</div>
		</div>
		<i class="iconfont">&#xe6a0;</i>
	</div>
	<!-- E 公告 -->
	<!-- S 买入 -->
	<div class="buy-wrap">
		<div class="total-value flex">
			<div class="div1">总价<input type="text" class="gf" value="1">GF</div>
			<div class="div2 flex-1"><span class="beans"><?php echo $beans_balance*1000; ?></span><i>豆</i></div>
			<div class="div3">+</div>
		</div>
		<a href="javascript:;" class="btn">立即买入</a>
		<p class="available">可用<span class="have_balance"><?php echo $user_info['upvaluation'] ?></span>GF</p>
	</div>
	<!-- E 买入 -->

	<!-- 横向菜单 -->
	<ul class="zsContMenu clearfix">
		<li class="on"><a href="javascript:;">当前投注</a></li>
		<li><a href="javascript:;">投注总计</a></li>
	</ul>
	<!--切换内容-->
	<div class="zsCont">
	    <!--标签1 对应展示 内容-->
	    <div class="item">
	        <ul class="bet-list">
	        	<li class="clearfix">
		        	<div class="fl">奖池金额</div>
		        	<div class="fr color666"><span class="num"><?php echo $Jackpot['value'] ? $Jackpot['value'] : 0; ?></span>GF</div>
	        	</li>
	        	<li class="clearfix">
		        	<div class="fl">我的投注</div>
		        	<div class="fr color666"><span class="num"><?php echo $user_info['put_upvaluation'] ? $user_info['put_upvaluation'] :  0; ?></span>GF</div>
	        	</li>
	        	<li class="clearfix">
					<div class="fl">我的奖金</div>
					<!-- 中奖总金额 -->
		        	<div class="fr color666"><span class="num"><?php echo $user_info['prize_upvaluation'] ? $user_info['prize_upvaluation'] : 0; ?></span>GF</div>
	        	</li>
	        </ul>
	    </div>
	    <!--标签2 对应展示内容-->
	    <div class="item hide">
	    	<ul class="bet-list">
	        	<li class="clearfix">
		        	<div class="fl">玩家总投注</div>
		        	<div class="fr color666"><span class="num"><?php echo $touzhu_balance ?$touzhu_balance :0; ?></span>GF</div>
	        	</li>
	        	<li class="clearfix">
		        	<div class="fl">我的分红奖励</div>
		        	<div class="fr color666"><span class="num"><?php echo $user_info['red_upvaluation'] ?  $user_info['red_upvaluation'] :0; ?></span>GF</div>
	        	</li>
	        	<li class="clearfix">
		        	<div class="fl">邀请分红</div>
		        	<div class="fr color666"><span class="num"><?php echo $user_info['invite_upvaluation'] ? $user_info['invite_upvaluation'] : 0; ?></span>GF</div>
	        	</li>
	        </ul>
	    </div>
	</div>

	<!-- S footer -->
	<div class="footBox">
		<footer>
			<a href="/index.php?m=user&c=trade&a=index&type=buy">
				<i class="iconfont">&#xe69d;</i>
				<span>交易所</span>
			</a>
			<a href="/index.php?m=user&c=exchange&a=index" class="cur">
				<i class="iconfont">&#xe69a;</i>
				<span>兑换</span>
			</a>
			<a href="/index.php?m=user&c=goods&a=index">
				<i class="iconfont">&#xe69e;</i>
				<span>商城</span>
			</a>
			<a href="/index.php?m=user&c=order&a=index">
				<i class="iconfont">&#xe69b;</i>
				<span>订单</span>
			</a>
			<a href="/index.php?m=user&c=home&a=index">
				<i class="iconfont">&#xe6a3;</i>
				<span>我的</span>
			</a>
		</footer>
	</div>
	<!-- E footer -->
	<!-- 买入成功弹窗 -->
	<div class="popup-shade" id="shade"></div>



	<div class="popup-content" id="success">
		<dl>
			<dt><img src="{THEME_PATH}images/success.png" alt="" width="30" height="30" class="icon-img"></dt>
			<dd>买入成功</dd>
		</dl>
		<a href="<?php echo U('index');?>" class="btn">确定</a>
	</div>



	<!-- 买入失败弹窗 -->
	<div class="popup-content" id="shibai">
		<dl class="failed">
			<dt><img src="{THEME_PATH}images/failed.png" alt="" width="30" height="30" class="icon-img"></dt>
			<dd>买入失败</dd>
			<dd class="dd2">升值链不足，请充值</dd>
		</dl>
		<a href="<?php echo U('index');?>" class="btn">确定</a>
	</div>


	<!-- 实名认证 -->
	<div class="popup-realName">
		<dl>
			<dt><img src="{THEME_PATH}images/real.png" alt="" width="125"></dt>
			<dd>实名认证 放心交易</dd>
		</dl>
		<ul class="flex flex-pack-justify">
			<li><a href="" class="btn">以后再说</a></li>
			<li><a href="" class="btn">前去认证</a></li>
		</ul>
	</div>
	<script src="{THEME_PATH}js/jquery-1.8.3.min.js"></script>
	<script src="{THEME_PATH}js/swiper.min.js"></script>
	<script src="/statics/js/layer/layer.js"></script>
	<script>
		//公告
		var announcementSwiper = new Swiper('#announcement', {
		        direction: 'vertical',
				loop: true,
		        autoplay:2000
		    })

	</script>
	<script>
		function tab(menus, conts) {
		    $(menus).click(function() {
		        var index = $(this).index();
                $(this).addClass("on").siblings().removeClass("on");
            	$(conts).eq(index).removeClass("hide").siblings().addClass("hide");
		    })
		}
		tab(".zsContMenu li", ".zsCont .item")



		$('.div3').click(function(){
		
			var beans = parseFloat($('.beans').text()) +1;
			var bili = <?php echo $beans_balance; ?>;
		
			var gf = parseFloat(beans/bili);
			gf = gf.toFixed(2)
		
			$('.beans').text(beans);
			$('.gf').val(gf);
		})

		$('.btn').click(function(){
			var gf = parseFloat($('.gf').val());
			var bili = <?php echo $beans_balance; ?>;
			var beans = gf*bili;
			
			var have_balance = parseFloat($('.have_balance').text());
			if(gf > have_balance){
				$("#shade,#shibai").show();
			
				return;
			}
			var beans = $('.beans').text();
			
			layer.confirm('确定要投注吗?', {btn: ['是','否'] }, function(index){
				$.ajax({
					url:"/index.php/?m=user&c=exchange&a=buy",
					type:'post',
					data:{gf:gf,beans:beans},
					dataType:'json',
					success:function(data){
						if(data.status ==0){
							layer.msg(data.info);
						}else{
						
							$("#shade,#success").show();
							// layer.close(index);
							return;
						}
					}
				});
				layer.close(index);
			});
		})

		$("input").blur(function(){
  			var gf = $('.gf').val();
			var bili = <?php echo $beans_balance; ?>;
			var beans = gf*bili;
			beans = beans.toFixed(4);
			
		
			$('.beans').text(beans);
		});

	</script>
</body>
</html>